home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / NeuralNet 195835132001.psc / NP / NueralProcessor.ctl (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-05-13  |  18.3 KB  |  490 lines

  1. VERSION 5.00
  2. Begin VB.UserControl NeuralProcessor 
  3.    AutoRedraw      =   -1  'True
  4.    ClientHeight    =   3600
  5.    ClientLeft      =   0
  6.    ClientTop       =   0
  7.    ClientWidth     =   4800
  8.    ForeColor       =   &H00FFFFFF&
  9.    ScaleHeight     =   240
  10.    ScaleMode       =   3  'Pixel
  11.    ScaleWidth      =   320
  12.    Begin VB.VScrollBar vS 
  13.       Height          =   2295
  14.       Index           =   2
  15.       LargeChange     =   10
  16.       Left            =   0
  17.       Max             =   360
  18.       Min             =   -360
  19.       SmallChange     =   2
  20.       TabIndex        =   3
  21.       Top             =   240
  22.       Visible         =   0   'False
  23.       Width           =   120
  24.    End
  25.    Begin VB.VScrollBar vS 
  26.       Height          =   2295
  27.       Index           =   1
  28.       LargeChange     =   10
  29.       Left            =   120
  30.       Max             =   360
  31.       Min             =   -360
  32.       SmallChange     =   2
  33.       TabIndex        =   2
  34.       Top             =   240
  35.       Visible         =   0   'False
  36.       Width           =   120
  37.    End
  38.    Begin VB.VScrollBar vS 
  39.       Height          =   2295
  40.       Index           =   0
  41.       LargeChange     =   10
  42.       Left            =   240
  43.       Max             =   360
  44.       Min             =   -360
  45.       SmallChange     =   2
  46.       TabIndex        =   1
  47.       Top             =   240
  48.       Visible         =   0   'False
  49.       Width           =   120
  50.    End
  51.    Begin VB.Label Label1 
  52.       AutoSize        =   -1  'True
  53.       Caption         =   "Label1"
  54.       Height          =   195
  55.       Left            =   0
  56.       TabIndex        =   0
  57.       Top             =   0
  58.       Width           =   480
  59.    End
  60. Attribute VB_Name = "NeuralProcessor"
  61. Attribute VB_GlobalNameSpace = False
  62. Attribute VB_Creatable = True
  63. Attribute VB_PredeclaredId = False
  64. Attribute VB_Exposed = True
  65. Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
  66. Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
  67. Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
  68. Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
  69. Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
  70. Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, lpPoint As POINTAPI) As Long
  71. Private Declare Function Rectangle Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
  72. Private Type POINTAPI
  73.         X As Long
  74.         Y As Long
  75. End Type
  76. Public Type typNeuron
  77. Hit As Boolean
  78. Value(0 To 2) As Integer
  79. End Type
  80. Private NeuralNet() As typNeuron
  81. Const m_def_nnWidth = 1
  82. Const m_def_nnHeight = 1
  83. Const m_def_nnDepth = 1
  84. Dim m_nnWidth As Long
  85. Dim m_nnHeight As Long
  86. Dim m_nnDepth As Long
  87. Private vStopNet As Boolean
  88. Private dX, dY, LastVS(0 To 2)
  89. Event Click()
  90. Event DblClick()
  91. Event KeyPress(KeyAscii As Integer)
  92. Event KeyUp(KeyCode As Integer, Shift As Integer)
  93. Event KeyDown(KeyCode As Integer, Shift As Integer)
  94. Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  95. Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  96. Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  97. Public Sub About()
  98. Attribute About.VB_UserMemId = -552
  99. MsgBox "This NeuralNet was created by: Cory J. Geesaman", vbInformation, "Created By"
  100. MsgBox "This was created because i got bored and had a passing thought of making something like this.", vbInformation, "Why This Was Made"
  101. MsgBox "The Background for this control was made by Richard Gardener", vbInformation, "Background"
  102. MsgBox "If you have any ideas for implementing this email: cory@geesaman.com, I am very-much open to suggestions for implementation into computer AI for charactors in my game.", vbInformation, "Got Ideas For The NeuralNet"
  103. MsgBox "Visit: http://www.naven.net/ for information on NAVEN, a very neat game I am making.", vbInformation, "Visit My Site"
  104. End Sub
  105. Private Sub nDrawLine(X1 As Long, X2 As Long, Y1 As Long, Y2 As Long, Color As Long, Optional Width As Long)
  106. If Width < 1 Then Width = 1
  107. Dim p_hPen As Long, p_old_hPen As Long, i_Point As POINTAPI
  108. p_hPen = CreatePen(0, CLng(1), Color)
  109. p_old_hPen = SelectObject(UserControl.hdc, p_hPen)
  110. MoveToEx UserControl.hdc, X1, Y1, i_Point
  111. LineTo UserControl.hdc, X2, Y2
  112. DeleteObject p_hPen
  113. DeleteObject p_old_hPen
  114. End Sub
  115. Public Function GetNNValue(X, Y, Z, V) As Integer
  116. GetNNValue = NeuralNet(X, Y, Z).Value(V)
  117. End Function
  118. Public Sub SetNNValue(X, Y, Z, V, Value)
  119. NeuralNet(X, Y, Z).Value(V) = Value
  120. End Sub
  121. Private Sub Draw3dPixel(ByVal ivertX As Double, ByVal ivertY As Double, ByVal ivertZ As Double, Color As Long)
  122. Dim cx As Single, cy As Single
  123. Dim sX As Single, sY As Single, sZ As Single
  124. Dim tempx As Single, tempy As Single, tempz As Single
  125.   cx = UserControl.ScaleWidth / 2
  126.   cy = UserControl.ScaleHeight / 2
  127.   s = 361
  128.   '// Camera Coordinates
  129.   If vS(0) = 0 Then sX = 1 Else sX = vS(0)
  130.   If vS(1) = 0 Then sY = 1 Else sY = vS(1)
  131.   If vS(2) = 0 Then sZ = 1 Else sZ = vS(2)
  132.   tempx = ivertX + sX '// transform origin
  133.   tempy = ivertY + sY '// to screen center
  134.   tempz = ivertZ + sZ '// to screen center
  135.       
  136.   PERS = s / (s + tempz) '//Get perspective factor
  137.   View_Plot_X = cx + tempx * PERS
  138.   View_Plot_Y = cy - tempy * PERS
  139.   DeleteObject SetPixel(UserControl.hdc, View_Plot_X, View_Plot_Y, Color)
  140. End Sub
  141. Private Sub Draw3dLine(ByVal ivertX As Double, ByVal ivertY As Double, ByVal ivertZ As Double, ByVal ivertX2 As Double, ByVal ivertY2 As Double, ByVal ivertZ2 As Double, Color As Long)
  142. Dim cx As Single, cy As Single
  143. Dim sX As Single, sY As Single, sZ As Single
  144. Dim tempx As Single, tempy As Single, tempz As Single
  145. Dim tempx2 As Single, tempy2 As Single, tempz2 As Single
  146. Dim View_Plot_X As Long, View_Plot_X2 As Long, View_Plot_Y As Long, View_Plot_Y2 As Long
  147.   cx = UserControl.ScaleWidth / 2
  148.   cy = UserControl.ScaleHeight / 2
  149.   s = 361
  150.   '// Camera Coordinates
  151.   If vS(0) = 0 Then sX = 1 Else sX = vS(0)
  152.   If vS(1) = 0 Then sY = 1 Else sY = vS(1)
  153.   If vS(2) = 0 Then sZ = 1 Else sZ = vS(2)
  154.   tempx = ivertX + sX '// transform origin
  155.   tempy = ivertY + sY '// to screen center
  156.   tempz = ivertZ + sZ '// to screen center
  157.   tempx2 = ivertX2 + sX '// transform origin
  158.   tempy2 = ivertY2 + sY '// to screen center
  159.   tempz2 = ivertZ2 + sZ '// to screen center
  160.       
  161.   PERS = s / (s + tempz) '//Get perspective factor
  162.   PERS2 = s / (s + tempz2) '//Get perspective factor
  163.   View_Plot_X = cx + tempx * PERS
  164.   View_Plot_Y = cy - tempy * PERS
  165.   View_Plot_X2 = cx + tempx2 * PERS2
  166.   View_Plot_Y2 = cy - tempy2 * PERS2
  167.   nDrawLine View_Plot_X, View_Plot_X2, View_Plot_Y, View_Plot_Y2, Color, 1
  168. End Sub
  169. Public Function InitNet(Width As Long, Height As Long, Depth As Long) As Boolean
  170. On Error GoTo ErrH
  171. Dim X As Long, Y As Long, Z As Long, Last As Long
  172. m_nnWidth = Width
  173. m_nnHeight = Height
  174. m_nnDepth = Depth
  175. ReDim NeuralNet(0 To Width - 1, 0 To Height - 1, 0 To Depth - 1) As typNeuron
  176. Last = 100
  177. X = 0
  178. Y = 0
  179. Z = 0
  180. Last = Rand(255, Last)
  181. NeuralNet(X, Y, Z).Value(0) = Last
  182. Last = Rand(255, Last)
  183. NeuralNet(X, Y, Z).Value(1) = Last
  184. Last = Rand(255, Last)
  185. NeuralNet(X, Y, Z).Value(2) = Last
  186. Z = Z + 1
  187. Loop Until Z >= Depth
  188. Y = Y + 1
  189. Loop Until Y >= Height
  190. X = X + 1
  191. Loop Until X >= Width
  192. InitNet = True
  193. Exit Function
  194. ErrH:
  195. InitNet = False
  196. Exit Function
  197. End Function
  198. Public Sub StartNet()
  199. vStopNet = False
  200. vS(0).Value = 1
  201. vS(1).Value = 1
  202. vS(2).Value = 1
  203. Dim a As Variant, b As Integer
  204. a = Time
  205. a = Split(a, " ")
  206. a = Split(a(0), ":")
  207. b = a(2)
  208. i = 0
  209. a = Time
  210. a = Split(a, " ")
  211. a = Split(a(0), ":")
  212. If b <> a(2) Then
  213. Label1.Caption = i & " FPS"
  214. i = 0
  215. b = a(2)
  216. End If
  217. i = i + 1
  218. DoEvents
  219. DrawNet
  220. DoEvents
  221. Loop Until vStopNet = True
  222. End Sub
  223. Public Sub StopNet()
  224. vStopNet = True
  225. End Sub
  226. Public Sub DrawSides()
  227. Draw3dLine 0, 0, 0, 0, 0, m_nnDepth - 1, vbWhite
  228. Draw3dLine 0, 0, 0, 0, m_nnHeight - 1, 0, vbWhite
  229. Draw3dLine 0, 0, 0, m_nnWidth - 1, 0, 0, vbWhite
  230. Draw3dLine 0, 0, m_nnDepth - 1, 0, m_nnHeight - 1, m_nnDepth - 1, vbWhite
  231. Draw3dLine 0, 0, m_nnDepth - 1, m_nnWidth - 1, 0, m_nnDepth - 1, vbWhite
  232. Draw3dLine 0, m_nnHeight - 1, 0, 0, m_nnHeight - 1, m_nnDepth - 1, vbWhite
  233. Draw3dLine 0, m_nnHeight - 1, m_nnDepth - 1, m_nnWidth - 1, m_nnHeight - 1, m_nnDepth - 1, vbWhite
  234. Draw3dLine m_nnWidth - 1, m_nnHeight - 1, m_nnDepth - 1, m_nnWidth - 1, 0, m_nnDepth - 1, vbWhite
  235. Draw3dLine m_nnWidth - 1, m_nnHeight - 1, m_nnDepth - 1, m_nnWidth - 1, m_nnHeight - 1, 0, vbWhite
  236. Draw3dLine m_nnWidth - 1, m_nnHeight - 1, 0, 0, m_nnHeight - 1, 0, vbWhite
  237. Draw3dLine m_nnWidth - 1, 0, 0, m_nnWidth - 1, m_nnHeight - 1, 0, vbWhite
  238. Draw3dLine m_nnWidth - 1, 0, 0, m_nnWidth - 1, 0, m_nnDepth - 1, vbWhite
  239. End Sub
  240. Public Sub DrawNet()
  241. UserControl.Cls
  242. Dim i As Long, Last As Long, i2 As Long, Last2 As Long, uD As Boolean, nuD As Boolean
  243. uD = NeuralNet(0, 0, 0).Hit
  244. nuD = Not uD
  245. i = 0
  246. Last = 255
  247. 'DrawSides
  248. UserControl.Refresh
  249. DoEvents
  250. Last = Rand(m_nnWidth - 1, Last)
  251. If NeuralNet(Last, 0, 0).Hit = uD Then
  252. i = i + 1
  253. '''''''''''''''''''''''''''''''''''''''''''''''''''
  254. i2 = 0
  255. Last2 = 255
  256. NeuronStepY Last, Last2, i2, uD, nuD
  257. '''''''''''''''''''''''''''''''''''''''''''''''''''
  258. NeuralNet(Last, 0, 0).Hit = nuD
  259. End If
  260. Loop Until i >= m_nnWidth
  261. UserControl.Refresh
  262. End Sub
  263. Private Sub NeuronStepY(Last As Long, Last2 As Long, i2 As Long, uD As Boolean, nuD As Boolean)
  264. Dim i3 As Long, Last3 As Long
  265. Last2 = Rand(m_nnHeight - 1, Last2)
  266. If NeuralNet(Last, Last2, 0).Hit = uD Then
  267. i2 = i2 + 1
  268. ''''''''''''''''''''''''''''
  269. i3 = 0
  270. Last3 = 255
  271. NeuronStepZ Last, Last2, Last3, i3, uD, nuD
  272. ''''''''''''''''''''''''''''
  273. NeuralNet(Last, Last2, 0).Hit = nuD
  274. End If
  275. Loop Until i2 >= m_nnHeight
  276. End Sub
  277. Private Sub NeuronStepZ(Last As Long, Last2 As Long, Last3 As Long, i3 As Long, uD As Boolean, nuD As Boolean)
  278. Last3 = Rand(m_nnDepth - 1, Last3)
  279. If NeuralNet(Last, Last2, Last3).Hit = uD Then
  280. i3 = i3 + 1
  281. NeuralNet(Last, Last2, Last3).Value(0) = NeuralNet(Last, Last2, Last3).Value(0) + GetNeuronStep(Last, Last2, Last3, 0)
  282. NeuralNet(Last, Last2, Last3).Value(1) = NeuralNet(Last, Last2, Last3).Value(1) + GetNeuronStep(Last, Last2, Last3, 1)
  283. NeuralNet(Last, Last2, Last3).Value(2) = NeuralNet(Last, Last2, Last3).Value(2) + GetNeuronStep(Last, Last2, Last3, 2)
  284. If (Last = 0 Or Last2 = 0 Or Last3 = 0 Or Last = m_nnWidth - 1 Or Last2 = m_nnHeight - 1 Or Last3 = m_nnDepth - 1) _
  285. And CombinedEdges(Last, Last2, Last3) Then
  286. Draw3dPixel Last, Last2, Last3, RGB(NeuralNet(Last, Last2, Last3).Value(0), NeuralNet(Last, Last2, Last3).Value(1), NeuralNet(Last, Last2, Last3).Value(2))
  287. End If
  288. NeuralNet(Last, Last2, Last3).Hit = nuD
  289. End If
  290. Loop Until i3 >= m_nnDepth
  291. End Sub
  292. Private Function CombinedEdges(Last As Long, Last2 As Long, Last3 As Long) As Boolean
  293. i = 0
  294. If Last = 0 Then i = i + 1
  295. If Last = m_nnWidth - 1 Then i = i + 1
  296. If Last2 = 0 Then i = i + 1
  297. If Last2 = m_nnHeight - 1 Then i = i + 1
  298. If Last3 = 0 Then i = i + 1
  299. If Last3 = m_nnDepth - 1 Then i = i + 1
  300. If i > 1 Then CombinedEdges = True Else CombinedEdges = True
  301. End Function
  302. Private Function GetNeuronStep(X As Long, Y As Long, Z As Long, Value As Byte) As Integer
  303. On Error Resume Next
  304. Dim MinX, MaxX, MinY, MaxY, MinZ, MaxZ, vX, vY, vZ, cV
  305. If X > 0 Then MinX = X - 1 Else MinX = X
  306. If X < m_nnWidth - 1 Then MaxX = X + 1 Else MaxX = X
  307. If Y > 0 Then MinY = Y - 1 Else MinY = Y
  308. If Y < m_nnHeight - 1 Then MaxY = Y + 1 Else MaxY = Y
  309. If Z > 0 Then MinZ = Z - 1 Else MinZ = Z
  310. If Z < m_nnDepth - 1 Then MaxZ = Z + 1 Else MaxZ = Z
  311. 'MinX = X - 1
  312. 'MinY = Y - 1
  313. 'MinZ = Z - 1
  314. 'MaxX = X + 1
  315. 'MaxY = Y + 1
  316. 'MaxZ = Z + 1
  317. cV = 0
  318. vX = MinX
  319. vY = MinY
  320. vZ = MinZ
  321. If NeuralNet(vX, vY, vZ).Value(Value) > NeuralNet(X, Y, Z).Value(Value) Then
  322. cV = cV + 1
  323. ElseIf NeuralNet(vX, vY, vZ).Value(Value) < NeuralNet(X, Y, Z).Value(Value) Then
  324. cV = cV - 1
  325. End If
  326. 'cV = cV + GetChangeNumber(vX, vY, vZ, X, Y, Z, Value)
  327. 'cV = cV + GetChangeNumber(vX, vY, Z + 1, X, Y, Z, Value)
  328. 'cV = cV + GetChangeNumber(vX, vY, Z - 1, X, Y, Z, Value)
  329. vZ = vZ + 1
  330. Loop Until vZ > MaxZ
  331. vY = vY + 1
  332. Loop Until vY > MaxY
  333. vX = vX + 1
  334. Loop Until vX > MaxX
  335. GetNeuronStep = cV
  336. End Function
  337. Public Function Rand(Max As Long, Optional Last) As Long
  338. If Last < 1 Then Last = 100
  339. If Max < 1 Then
  340. Rand = 0
  341. Exit Function
  342. End If
  343. a = Rnd(Last)
  344. b = Mid(a, InStr(1, a, ".", vbTextCompare) + 1, Len(Str(Max)) - 1)
  345. If b > Max Then
  346. b = b - ((b \ Max) * Max)
  347. End If
  348. If b < 1 Then b = 0
  349. Rand = b
  350. End Function
  351. Public Property Get Appearance() As Integer
  352. Attribute Appearance.VB_Description = "Returns/sets whether or not an object is painted at run time with 3-D effects."
  353.     Appearance = UserControl.Appearance
  354. End Property
  355. Public Property Let Appearance(ByVal New_Appearance As Integer)
  356.     UserControl.Appearance() = New_Appearance
  357.     PropertyChanged "Appearance"
  358. End Property
  359. Public Property Get BackColor() As OLE_COLOR
  360. Attribute BackColor.VB_Description = "Returns/sets the background color used to display text and graphics in an object."
  361.     BackColor = UserControl.BackColor
  362. End Property
  363. Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
  364.     UserControl.BackColor() = New_BackColor
  365.     PropertyChanged "BackColor"
  366. End Property
  367. Public Property Get BorderStyle() As Integer
  368. Attribute BorderStyle.VB_Description = "Returns/sets the border style for an object."
  369.     BorderStyle = UserControl.BorderStyle
  370. End Property
  371. Public Property Let BorderStyle(ByVal New_BorderStyle As Integer)
  372.     UserControl.BorderStyle() = New_BorderStyle
  373.     PropertyChanged "BorderStyle"
  374. End Property
  375. Private Sub UserControl_Click()
  376.     RaiseEvent Click
  377. End Sub
  378. Private Sub UserControl_DblClick()
  379.     RaiseEvent DblClick
  380. End Sub
  381. Private Sub UserControl_KeyPress(KeyAscii As Integer)
  382.     RaiseEvent KeyPress(KeyAscii)
  383. End Sub
  384. Private Sub UserControl_KeyUp(KeyCode As Integer, Shift As Integer)
  385.     RaiseEvent KeyUp(KeyCode, Shift)
  386. End Sub
  387. Private Sub UserControl_KeyDown(KeyCode As Integer, Shift As Integer)
  388.     RaiseEvent KeyDown(KeyCode, Shift)
  389. End Sub
  390. Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  391. If Button = 1 Then
  392. dX = X
  393. dY = Y
  394. LastVS(0) = vS(0).Value
  395. LastVS(1) = vS(1).Value
  396. LastVS(2) = vS(2).Value
  397. End If
  398.     RaiseEvent MouseDown(Button, Shift, X, Y)
  399. End Sub
  400. Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  401. If Button = 1 Then
  402. tx = LastVS(0) + (dX - X)
  403. ty = LastVS(1) + (dY - Y)
  404. If tx = 0 Then tx = 1
  405. If ty = 0 Then ty = 1
  406. If tx < -360 Then tx = -360
  407. If ty < -360 Then ty = -360
  408. If tx > 360 Then tx = 360
  409. If ty > 360 Then ty = 360
  410. vS(0).Value = -tx
  411. vS(1).Value = ty
  412. End If
  413.     RaiseEvent MouseMove(Button, Shift, X, Y)
  414. End Sub
  415. Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  416.     RaiseEvent MouseUp(Button, Shift, X, Y)
  417. End Sub
  418. Public Property Get MouseIcon() As Picture
  419. Attribute MouseIcon.VB_Description = "Sets a custom mouse icon."
  420.     Set MouseIcon = UserControl.MouseIcon
  421. End Property
  422. Public Property Set MouseIcon(ByVal New_MouseIcon As Picture)
  423.     Set UserControl.MouseIcon = New_MouseIcon
  424.     PropertyChanged "MouseIcon"
  425. End Property
  426. Public Property Get MousePointer() As Integer
  427. Attribute MousePointer.VB_Description = "Returns/sets the type of mouse pointer displayed when over part of an object."
  428.     MousePointer = UserControl.MousePointer
  429. End Property
  430. Public Property Let MousePointer(ByVal New_MousePointer As Integer)
  431.     UserControl.MousePointer() = New_MousePointer
  432.     PropertyChanged "MousePointer"
  433. End Property
  434. Public Property Get Picture() As Picture
  435. Attribute Picture.VB_Description = "Returns/sets a graphic to be displayed in a control."
  436.     Set Picture = UserControl.Picture
  437. End Property
  438. Public Property Set Picture(ByVal New_Picture As Picture)
  439.     Set UserControl.Picture = New_Picture
  440.     PropertyChanged "Picture"
  441. End Property
  442. Public Property Get nnWidth() As Long
  443.     nnWidth = m_nnWidth
  444. End Property
  445. Public Property Let nnWidth(ByVal New_nnWidth As Long)
  446.     m_nnWidth = New_nnWidth
  447.     PropertyChanged "nnWidth"
  448. End Property
  449. Public Property Get nnHeight() As Long
  450.     nnHeight = m_nnHeight
  451. End Property
  452. Public Property Let nnHeight(ByVal New_nnHeight As Long)
  453.     m_nnHeight = New_nnHeight
  454.     PropertyChanged "nnHeight"
  455. End Property
  456. Public Property Get nnDepth() As Long
  457.     nnDepth = m_nnDepth
  458. End Property
  459. Public Property Let nnDepth(ByVal New_nnDepth As Long)
  460.     m_nnDepth = New_nnDepth
  461.     PropertyChanged "nnDepth"
  462. End Property
  463. Private Sub UserControl_InitProperties()
  464.     m_nnWidth = m_def_nnWidth
  465.     m_nnHeight = m_def_nnHeight
  466.     m_nnDepth = m_def_nnDepth
  467. End Sub
  468. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
  469.     UserControl.Appearance = PropBag.ReadProperty("Appearance", 1)
  470.     UserControl.BackColor = PropBag.ReadProperty("BackColor", &H8000000F)
  471.     UserControl.BorderStyle = PropBag.ReadProperty("BorderStyle", 0)
  472.     Set MouseIcon = PropBag.ReadProperty("MouseIcon", Nothing)
  473.     UserControl.MousePointer = PropBag.ReadProperty("MousePointer", 0)
  474.     Set Picture = PropBag.ReadProperty("Picture", Nothing)
  475.     m_nnWidth = PropBag.ReadProperty("nnWidth", m_def_nnWidth)
  476.     m_nnHeight = PropBag.ReadProperty("nnHeight", m_def_nnHeight)
  477.     m_nnDepth = PropBag.ReadProperty("nnDepth", m_def_nnDepth)
  478. End Sub
  479. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
  480.     Call PropBag.WriteProperty("Appearance", UserControl.Appearance, 1)
  481.     Call PropBag.WriteProperty("BackColor", UserControl.BackColor, &H8000000F)
  482.     Call PropBag.WriteProperty("BorderStyle", UserControl.BorderStyle, 0)
  483.     Call PropBag.WriteProperty("MouseIcon", MouseIcon, Nothing)
  484.     Call PropBag.WriteProperty("MousePointer", UserControl.MousePointer, 0)
  485.     Call PropBag.WriteProperty("Picture", Picture, Nothing)
  486.     Call PropBag.WriteProperty("nnWidth", m_nnWidth, m_def_nnWidth)
  487.     Call PropBag.WriteProperty("nnHeight", m_nnHeight, m_def_nnHeight)
  488.     Call PropBag.WriteProperty("nnDepth", m_nnDepth, m_def_nnDepth)
  489. End Sub
  490.